﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

namespace Hands.UriRewrite
{
    internal class UriRootPathQuery : IQuery
    {
        private static Regex rootPathRegex = null;

        private delegate void Rewrite(string path);

        static UriRootPathQuery()
        {
            ConfigFileReader.readConfigFile();
        }

        internal static void initRootPathRegex(string rootPath)
        {
            rootPathRegex = new Regex(rootPath, RegexOptions.Compiled);
        }

        #region IQuery 成员

        public IRewrite find(string path)
        {
            return ConfigStorage.find(rootPathRegex.Match(path).Value);
        }

        #endregion
    }
}
